Haskell is new here. I am trying to understand this example from the Haskell library diagrams. In particular, there is such a line:
diagrams
Just t = <thing>where <thing>has typeMaybe (Tree a)
Just t = <thing>
<thing>
Maybe (Tree a)
I do not understand what this does. I understand that we need to get the value from Maybe. I replaced this line of code with
Maybe
t = fromJust <thing>
and it works the same way. Is there a difference between the two lines, and can anyone explain what the first line does?
fromJust pretty much equivalent to:
fromJust
fromJust :: Maybe a -> a fromJust (Just t) = t
, ! , Maybe Just, Nothing, fromJust, , , .
Just
Nothing
,
. (fromJust , , )
$ ghci Prelude> :m +Data.Maybe Prelude Data.Maybe> let t = fromJust Nothing Prelude Data.Maybe> t *** Exception: Maybe.fromJust: Nothing Prelude Data.Maybe> let Just t = Nothing Prelude Data.Maybe> t *** Exception: <interactive>:7:5-20: Irrefutable pattern failed for pattern Data.Maybe.Just t
, Maybe Just, .
:
Just t = Just 3 3 t. ghci . fromJust , .
Just t = Just 3
t
ghci
Source: https://habr.com/ru/post/1541666/More articles:Получить индексы пересекающихся строк Numpy 2d Array - pythonpandas pivot_table multiple aggfunc - pythonpython call from R with instant console output - pythonDetermine the difference between WinRT and Windows 8 - c #UIButton has a point when it is selected inside UIToolbar - iosMultiple AggFun in Pandas - pythonHow to create a package in an existing directory using RStudio - rBash: merge multiple files and add "\ newline" between them? - fileReturns false vs, throwing an exception in Ruby. When and why? - ruby | fooobar.comWhy does addEventListener light up before the event, if at all? - javascriptAll Articles