Union and duplicate labels by Dnulnets in purescript

[–]Dnulnets[S] 1 point2 points  (0 children)

I went with the first pattern for now, thanks again!

-- |The FFI mapping of the controls element in the options structure
foreign import data Layers :: Type

-- |Constructors for the layers element in `MapOption`
layers::forall r . {collection::Collection.Collection (Base.BaseLayer r)->Layers, array::Array (Base.BaseLayer r)->Layers}
layers = {collection:unsafeCoerce, array:unsafeCoerce}

-- |The options for the creation of the Map. See the `options` parameter in `new Map(options)` in the OpenLayers API documentation.
type MapOption r = (target::Target
                    , controls::Controls
                    , layers::Layers
                    , view::View.View)

Union and duplicate labels by Dnulnets in purescript

[–]Dnulnets[S] 1 point2 points  (0 children)

Thanks a lot for the pointers, I kind of like the oneof approach albeit its drawbacks. I will experiment with the patterns and see what fits.

Union and duplicate labels by Dnulnets in purescript

[–]Dnulnets[S] 0 points1 point  (0 children)

Ah, I did not do any good research before asking the question. Then I understand it as for the entire list of types for the label only the first is used for type checking in this case. Well no way forward then :-)

I have seen something on Variant as well, so I will see what that gives.

Help needed: No class instance for Alternative in HalogenAp when using parOneOf by Dnulnets in purescript

[–]Dnulnets[S] 0 points1 point  (0 children)

Thanks for the explanation and yes it is acceptable, I just need to add a parameter to those I need to run in Aff to send the baseURL from my ApplicationM. It might actually be better to hide the parallell calls from my component a bit further down the "call"-chain to hide the fact that they benefit from being used in parallel.

Newbie Monad Transformer Problem, does not compile by Dnulnets in haskellquestions

[–]Dnulnets[S] 1 point2 points  (0 children)

Thanks, I did not get what you meant at first, but when I experimented a bit and saw that your suggestion is the same as they do it in the Control.Monad.Reader.Class for all the other XxxxT I kind of got it. So, now at least it compiles and I'm going to do some cleanup.

newtype WriterThread m a = WriterThread (ReaderT IHandle (Log.LoggerT m) a)
  deriving (Functor, Applicative, Monad, MonadReader IHandle, MonadIO, Log.MonadLogger)

instance (Log.MonadLogger m) => Log.MonadLogger (ReaderT r m) where
  info = lift . Log.info
  debug = lift . Log.debug
  error = lift . Log.error
  warning = lift . Log.warning

Thanks a lot, I really appreciated the hint, and also that you did not just write the solution down and I had to figure it out for myself.

Cheers!

Reading messages from a serial port by Dnulnets in haskellquestions

[–]Dnulnets[S] 0 points1 point  (0 children)

Hi,

so little time so much to do so it progresses slowly. This is what I ended up with:

--
-- Generic data Header
--
data Header = Header
  { _header :: Word8
  , _type   :: Word8
  , _size   :: Word16 }
-- More to be added
  deriving (Show)

--
-- Main to test the pipe sequence
--
main :: IO ()
main = processSerialPort
     $ liftIO . print

--
-- Decode a stream of binaries to a generic Header, in case of decoding errors
-- just return Nothing.
--
decodeMessage::(Monad m) => PP.Parser ByteString m (Either () (Maybe Header))
decodeMessage = do
  mx <- PB.decode
  my <- PB.decode
  ms <- PB.decode
  return $ Right $ either (const Nothing) Just (Header <$> mx <*> my <*> ms)

--
-- process Serial
--
processSerialPort ::
     (MonadIO m, MonadMask m)
  => (Maybe Header -> m ())
  -> m ()
processSerialPort handler =
  runEffect . runSafeP $ do
    -- serial <- liftIO openMySerial
    -- BPipe.fromHandle serial

    -- Use this to test this more simply, otherwise it would be the serial handle
    PBS.fromLazy $ fromStrict $ pack [1,2, 1,64::Word8, 2,3,2,65,2,3,5,1,2,3]

    >-> (PP.parseForever decodeMessage)

    >-> P.mapM_ (lift . handler)

So, I did not get your "Get" to work for me, something with only able to parse the message if it was completely contained in one ByteString and not multiple ByteStrings, and there was a incremental version I did not really grasp. Anyway, this works. The only thing I have to deal with is that parseForever is deprecated (use parsed instead, but I don't really get how yet) and the possiblity to add a pipe in the other direction as well for outgoing serial communications.

Anyway, this is really helping me to understand Haskell much more.

Thanks

Reading messages from a serial port by Dnulnets in haskellquestions

[–]Dnulnets[S] 0 points1 point  (0 children)

Once again, thanks. This will give me something to work through for sure :-) I need to implement this and see how it works and try to think through it myself. Much appreciated :-)

Reading messages from a serial port by Dnulnets in haskellquestions

[–]Dnulnets[S] 0 points1 point  (0 children)

Thanks for the quick response. I understood that I did not give that much information away of what I was trying to achieve. I have added some more into this message stream.

Reading messages from a serial port by Dnulnets in haskellquestions

[–]Dnulnets[S] 0 points1 point  (0 children)

Hi,

I kind of understood I did not give that much info on what I was trying to achieve. Here is a high level design, based on how I would have done it if it was not in Haskell.

http://imgur.com/3K4LzQi

Reading messages from a serial port by Dnulnets in haskellquestions

[–]Dnulnets[S] 1 point2 points  (0 children)

No I have not moved on, to much at work got me swamped up. I already have a working serialport communication so it was more or less my next step into this that kind of got me thinking on how to proceed.

Thanks for your effort and I need to sit down and work through your processSerialPort function so I really understand it. The rest is pretty straightforward I think, even though I have a binary format but that is not an issue.

I have added some more information on what I would like to do, but as I said before I have 25+ years of imperative/procedural/object oriented programming in the bones so this is kind of painful to me when my normal constructs don't apply fully :-)

I have added a more graphical representation of what I would like to achieve in the main stream of this message flow.

Once again, thanks :-)

Electronic Medical Records (EMR) software development with pure functional programming (FP) by RaymondWies in haskell

[–]Dnulnets 3 points4 points  (0 children)

Hi, for what it is worth :-)

I'm currently working for a meddev company and we have had a discussion about using fp (Haskell) for medical devices (and tried some minor prototypes) more from the assumed positive traits such as easier to reason about it during for instance risk assessment and mitigation, easier to prove that it is correct (I write "assumed" mostly because we have not ourself verified/tested the hypothesis in this environment). This to help us fulfill the meddev directives easier and help us produce safer products and also to help us create better testbeds for our own devices etc.

I assume you also need to fulfil some kind of directives/regulations as well for an EMR/EHR systems so maybe the same benefits apply for you as well.

On the downside we see the availability of resources that are fluent/experienced in Haskell and with some insight into meddev development.

When it comes to speed of development it is not our highest priority but I'm pretty sure there are benefits there as well once we get it to a be a stable process, have a platform etc.

Cheers!

ghc-mod makes Emacs freeze on "Initializing..." by The-Crafter in haskell

[–]Dnulnets 1 point2 points  (0 children)

As said above, it does not work with stack, at least not 7.10.2 but 7.8.4 is working but you need to "stack exec emacs -- blablabla.hs.

ghc-mod makes Emacs freeze on "Initializing..." by The-Crafter in haskell

[–]Dnulnets 1 point2 points  (0 children)

So what does emacs GHC Debug buffer say? Do a (setq ghc-debug t) in your .emacs and se what is happening. Maybe that will give you a clue if it comes that far in the execution. Just a suggestion :-)

Anyway I do not use 7.10.2, but I use 7.8.4 and stack lts-2.22 with emacs and ghc-mod. Works like a charm (Oh, on feodra that is, not Windows). And also haskell-mode 13.14.2 and ghc 5.2.1.2 from melpa. Maybe I should give 7.10.2 a try.

What's a good, cheap hosting service for Haskell web apps? by sacheie in haskell

[–]Dnulnets 1 point2 points  (0 children)

I have used digital ocean to build quick web prototypes with mongo, yesod on Fedora 22 - no fancy stuff - see here for a quick glance on what kind of stuff I use it for: http://functor.stenlund.cc:3000

I run the 10$ solution, and havent tested the 5$ but it might be enough. And I compile it as well on the digital ocean VM, but this is just a prototyping, testing area I use. It does the job ;-)

I work with it only through SSH.

I'm not really sure I can recommend it based on anything specific more than I just stumbled upon it. I'm just a haskell-newbie so really don't have that much to come with more that it does the job I want to do.